﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;
using System.Web.UI.DataVisualization.Charting;
using LDSP.BRL;

namespace LDSP.UI.EnterpriseAdmin
{
    public partial class ReportImg : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.RenderReport();
        }

        protected void RenderReport()
        {
            ReportInfo ri = this.Session["principalReport"] as ReportInfo;
            if (ri != null)
            {
                int columns = ri.DataSource.Rows.Count;
                if (columns < 10)
                {
                    cht_report.Height = 330;
                }
                else
                {
                    cht_report.Height = columns * 30 + 60;
                }
                cht_report.Width= 1000;

                cht_report.DataSource = ri.DataSource;
                cht_report.RenderType = RenderType.BinaryStreaming;
                cht_report.ImageStorageMode = ImageStorageMode.UseImageLocation;
                cht_report.ImageLocation = "TmpImg";
                cht_report.Series[0].XValueMember = ri.XName;
                cht_report.Series[0].YValueMembers = ri.YName;
                cht_report.Titles.Add(ri.Title);
                this.SetApperance(cht_report);
                cht_report.DataBind();
            }

        }

        protected void SetApperance(Chart Chart1)
        {
            // Set Back Color
            Chart1.BackColor = Color.White;
            Chart1.BackSecondaryColor = Color.Coral;
            // Set Gradient Type
            Chart1.BackGradientStyle = GradientStyle.LeftRight;
            // Set Border Color
            Chart1.BorderColor = Color.MidnightBlue;
            // Set Border Style
            Chart1.BorderStyle = BorderStyle.Solid;
            // Set Border Width
            Chart1.BorderWidth = 2;
            Chart1.BackImageTransparentColor = Color.White;

            Chart1.ChartAreas[0].BackColor = Color.Transparent;
            Chart1.ChartAreas[0].BorderColor = Color.Black;
            Chart1.ChartAreas[0].BorderDashStyle = ChartDashStyle.Solid;
            Chart1.ChartAreas[0].AxisX.Interval = 1;
            Chart1.ChartAreas[0].AxisY.Interval = 1;
            Chart1.Titles[0].Font = new Font("Times New Roman", 14, FontStyle.Bold);
            Chart1.Titles[0].ForeColor = Color.MidnightBlue;

            Chart1.Series[0].Color = Color.CornflowerBlue;
            Chart1.Series[0].BackSecondaryColor = Color.SkyBlue;
            Chart1.Series[0].BackGradientStyle = GradientStyle.VerticalCenter;
            Chart1.Series[0].BorderColor = Color.Gray;
            Chart1.Series[0].BorderWidth = 1;
            Chart1.Series[0].BorderDashStyle = ChartDashStyle.Solid;
            Chart1.Series[0].ShadowOffset = 2;

        }
    }
}